<template>
  <div class="container" :style="'height: '+docheight+'px'">
    <leftcont></leftcont>
    <div class="righCont">
      <topcont></topcont>
      <div class="content">
        <div class="payTable">
          <div class="trendTop">用户列表({{ total }})</div>
          <div class="tableCont">
            <div class="tableSerchCont">
              <div class="serchItem">
                <el-input v-model="serchVal" placeholder="请输入用户昵称"></el-input>
              </div>
              <div class="headBtn">
                <btn value="搜索" @click="serchFn"></btn>
              </div>
            </div>
            <el-table
              :data="tableData"
              style="width: 100%">
              <el-table-column
                prop="nick_name"
                width="200"
                show-overflow-tooltip
                label="用户昵称"
              >
              </el-table-column>
              <el-table-column
                prop="nick_name"
                label="用户头像"
              >
              <template slot-scope="scope">
                <img style="height: 40px;" :src="scope.row.head_img+ossSrc" />
              </template>
              </el-table-column>
              <el-table-column
                prop="consumption_price"
                label="消费金额"
              >
              </el-table-column>
              <el-table-column
                prop="order_sum"
                label="订单总数"
              >
              </el-table-column>
              <el-table-column
                prop="qx_cs"
                label="取消订单次数"
              >
              </el-table-column>
            </el-table>
            <div class="pageCont">
              <el-pagination
                background
                layout="prev, pager, next"
                :page-size="per_page"
                :current-page="page"
                @current-change="pageFn"
                :total="total">
              </el-pagination>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import leftcont from '@/components/leftCont.vue'
  import topcont from '@/components/topCont.vue'
  import btn from '@/components/public/btn.vue'
  import {User} from "@/http/api"

  export default {
    components: {leftcont,topcont,btn},
    data() {
      return {
        typeVal:'',
        serchVal:'',
        sexVal:'',
        typeArr:[
          {
            value: '',
            label: '全部'
          },{
            value: '1',
            label: '正常'
          },{
            value: '2',
            label: '禁用'
          }
        ],
        sexArr:[
          {
            value: '',
            label: '全部'
          },{
            value: '1',
            label: '男'
          },{
            value: '2',
            label: '女'
          }
        ],

        tableData:[],
        page:1,
        per_page:5,
        total:0,
      }
    },
    props: {},
    methods:{
      pageFn(index){
        this.page = index
        this.getdata()
      },
      serchFn(){ 
        this.page = 1
        this.total = 0
        this.getdata()
      },
      getdata(){
        var data ={
          nick_name:this.serchVal,
          page:this.page,
          per_page:this.per_page,
        }
        User(data).then((res)=>{
          if(res.data.code==1){
            this.tableData = res.data.data.data //把最新的数组赋值给tableData
            this.total = res.data.data.total
          }else{
            this.$message(res.data.msg)
          }
        }).catch((err)=>{
          this.$message('服务器请求超时');
        })
      }
    },
    mounted(){
    },
    created() {
      this.getdata()
    },
  }
</script>

<style scoped lang="less">
  .container{
    width: 100%;
    display: flex;
    overflow: hidden;
    .righCont{
      display: flex;
      flex-direction: column;
      flex: 1;
      margin-left: 15px;
      height: 100%;
      width: 10px;
      background-color: #F4F8FF;
      .content{
        padding: 20px;
        box-sizing: border-box;
        width: 100%;
        flex: 1;
        overflow: auto;
        .payTable{
          margin-top: 20px;
          width: 100%;
          background-color: #fff;
          padding: 15px;
          box-sizing: border-box;
          .trendTop{
            font-weight: bold;
            font-size: 16px;
            cursor: pointer;
          }
          .tableCont{
            width: 100%;
            margin-top: 15px;
            .redBtn{
                color: #F56C6C;
              }
              .blueBtn{
                color: #96A1FE;
              }
              .greenBtn{
                color: #85CE61;
              }
              .blackBtn{
                color: #666;
              }
            .tableSerchCont{
              width: 100%;
              display: flex;
              justify-content: flex-end;
              margin-bottom: 10px;
              .serchItem{
                width: 150px;
                margin-left: 10px;
              }
              .headBtn{
                margin-left: 10px;
              }
            }
            .ctrolBtn{
              display: flex;
              .text_btn{
                margin: 0 5px;
                cursor: pointer;
                font-size: 14px;
              }
              

            }
            .pageCont{
              padding: 30px 0;
              display: flex;
              justify-content: center;
            }
          }
        }
      }
    }
  }
</style>
